package com.wcards.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wcards.config.R;
import com.wcards.dto.OrderInfoDTO;
import com.wcards.entity.OrderInfo;
import com.wcards.service.OrderInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/*
 * 阿伟
 * */
@Api("订单模块")
@RestController
@Slf4j
@RequestMapping("/orders")
public class OrderController {
    @Autowired
    private OrderInfoService orderInfoService;


    //生成订单
    @ApiOperation("生成订单")
    @PostMapping("/addOrder")
    public R<String> addOrder(@RequestBody OrderInfoDTO orderInfoDTO) {
        return orderInfoService.creatOrder(orderInfoDTO);
    }

    //删除订单
    @ApiOperation("订单删除")
    @DeleteMapping("/deleteOrder")
    public R<String> deleteOrder(Integer id) {
        return orderInfoService.deleteOrder(id);
    }

    /*
     * 修改订单
     * */
    @ApiOperation("修改订单")
    @PutMapping("/updateOrder")
    public R<String> updateOrder(@RequestBody OrderInfoDTO orderInfoDTO) {
        return orderInfoService.updateOrder(orderInfoDTO);

    }

    /*
     * 查询订单
     * */
    @ApiOperation("查询订单")
    @GetMapping("/findOrder")
    public R<Page<OrderInfo>> findOrder(@RequestBody OrderInfoDTO orderInfoDTO, Integer pageSize, Integer pageNumber) {

        return orderInfoService.findOrder(orderInfoDTO, pageSize, pageNumber);
    }
}
